package com.hubei.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import com.hubei.pojo.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

public class TwoController implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        List<User> list = new ArrayList<>();
        list.add(new User(1, "xavier", "男"));
        list.add(new User(2, "cherish", "女"));
        list.add(new User(3, "jony", "男"));

        ModelAndView mav = new ModelAndView();
        mav.addObject("userList", list);
        mav.setViewName("/WEB-INF/jsp/one.jsp"); // 改为逻辑视图名，由视图解析器解析
//        try{
//            Thread.sleep(5000);
//        }catch (Exception e){
//            e.printStackTrace();
//
//        }
        return mav; // 必须返回mav对象
    }
}
